<?php
/**
 * Smarty plugin
 * @package Smarty
 * @subpackage plugins
 */


/**
 * Smarty {eek_to_eur} function plugin
 *
 * Type:     function<br />
 * Name:     eek_to_eur<br />
 * Purpose:  Convert prices from EEK to EUR
 * 
 * @author   Alari Lukk
 * @param array
 * @param Smarty
 * @return string
 */
function smarty_function_eek_to_eur( $params, &$smarty) {
	$str = (string)$params['eek'];
	
	if( strpos($str, ',') !== false ) {
		$delimiter = ',';
		$str = str_replace( ',', '.', $str );
	} else {
		$delimiter = '.';
	}
	
	$str = str_replace( ' ', '', $str );
	return number_format( round((float)$str / 15.64664, 2), 2, $delimiter, ' ' );
}
?>